﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet"
	href="<%=path%>/script/ztree_3.3/css/zTreeStyle/zTreeStyle.css"
	type="text/css" />
<script type="text/javascript"
	src="<%=path%>/script/jquery-1.7.2.min.js"></script>
<script type="text/javascript"
	src="<%=path%>/script/ztree_3.3/js/jquery.ztree.all-3.3.js"></script>
<script language="javascript">

var setting = {
		data : {
			simpleData : { //simpleData表示这个一个简单的ztree树形结构（还有一种标准结构，具体查看Ztreeapi）
				enable : true
			}
		},
		callback: {
			onClick: function (event, treeId, treeNode) {
			  var isLeaf=treeNode.isLeaf;
			
			  if(isLeaf=="Y" || isleaf=="y"){
				  var href=treeNode.href;
				  //让右边的框架打开此链接
				  var topparent=window.parent; //拿到父窗口
				  var frameArray=topparent.frames; //拿到窗口的所有框架的集合
				  var rightFrame=frameArray["rightFrame"];  //拿到父窗口集合中的右边的框架
				  
				  rightFrame.location.href="${pageContext.request.contextPath}"+href;
				  
			  }
				
			}
		}
	};

	var loadURL="<%=path%>/mainAction!leftTree?date="+new Date()+"";
	$.get(loadURL, function(treeDate) {  //从数据库中取到json格式的数据（节点数据）返回给ztree使用。

		$.fn.zTree.init($("#treeDemo"), setting, treeDate); //把ztree树形结构按照setting的规则，节点为treeDate，加载到id为ztreeDemo的标签中
	}, "json");
	

</script>
<style type="text/css">

body {
	margin:0px;
	padding:0px;
	font-size: 12px;
}

</style>
</head>
<body>


	<div class="zTreeDemoBackground left" > <!-- overflow-y：scroll 大小超过设置的范围会出现滚动条 -->
		<ul id="treeDemo" class="ztree"></ul>
	</div>
</body>
</html>
